import 'package:flutter/material.dart';
import 'package:test_flutter/utils/factory/Fit.dart';

class EditText2 extends StatefulWidget {

  String title;
  String AssetName;
  bool enabled = true;
  String value;
  ValueChanged<String> onChanged;
  GestureTapCallback onTab;
  EditText2(this.title,this.AssetName,{this.value,this.enabled,this.onChanged,this.onTab});

  @override
  EditTextState createState() => new EditTextState();

}

class EditTextState extends State<EditText2> {

  @override
  Widget build(BuildContext context) {
   // widget._Controller.text = widget.value;
    return new Stack(
      alignment: FractionalOffset.bottomCenter,
      children: <Widget>[
        GestureDetector(
          onTap: widget.onTab,
          child: new Container(
            padding: EdgeInsets.only(
                left: Fit.scaleX(80),
                top: Fit.scaleX(50),
                right: Fit.scaleX(80),
                bottom: Fit.scaleX(10)),
            width: Fit.scaleX(1920),
            height: Fit.scaleY(180),
            color: Colors.white,
            child: new Row(
              children: <Widget>[
                new Image(
                    width: Fit.scaleX(80),
                    height: Fit.scaleY(80),
                    image: new ExactAssetImage(widget.AssetName)),
                new Expanded(
                    child: new Padding(
                  padding: EdgeInsets.only(left: Fit.scaleX(45)),
                  child: new TextField(
                    style: new TextStyle(
                        fontSize: Fit.scaleTextSize(40), color: Color(0xffcdcdcd)),
                    controller: TextEditingController.fromValue(TextEditingValue(
                      // 设置内容
                        text: widget.value,
                        // 保持光标在最后
                        selection: TextSelection.fromPosition(TextPosition(
                            affinity: TextAffinity.downstream,
                            offset: widget.value.length)))),
                    decoration: new InputDecoration(
                        hintText: widget.title, border: InputBorder.none),
                    obscureText: false,
                    enabled: widget.enabled,
                    onChanged:widget.onChanged,
                  ),
                )),
              ],
            ),
          ),
        ),
        new Align(
          child: new Padding(
            padding: new EdgeInsets.only(
                left: Fit.scaleX(50),
                right: Fit.scaleX(50)),
            child: Align(
              child: new Divider(
                height: 0.5,
                color: Colors.black26,
              ),
            ),
          ),
        ),
      ],
    );
  }

}
